// pages/index/index.js
wx.cloud.init({
  env: 'ccntst-8gsp6zkw250f8e38',
  traceUser: true,
})
const db=wx.cloud.database()
Page({

  item:function(){
wx.navigateTo({
  url: '/pages/item/item',
})
  },
  dpl:function(){
    wx.navigateTo({
      url: '/pages/dpfl/dp',
    })
     },
     xiqu:function(){
       wx.navigateTo({
         url: '/pages/xiqu/xiqu',
       })
        },
        nanhu:function(){
         wx.navigateTo({
           url: '/pages/nanhu/nanhu',
         })
          },
          two:function(){
            wx.navigateTo({
              url: '/pages/two/two',
            })
             },
             three:function(){
              wx.navigateTo({
                url: '/pages/three/three',
              })
               },
  /**
   * 页面的初始数据
   */
  data: {
    subjects:[],
    boards:[
      {key: 'rmbs',btn1:'',btn2:'',btn3:'',btn4:'',name:[],src:[],jj:'',zd:''}
    ]
  },
  retrive(index){
    let that = this
    let db = wx.cloud.database()
    let rmbs = db.collection(this.data.boards[index].key)
    rmbs.get({
      success(res){
        console.log(res);
        let myboards = that.data.boards
        myboards[index].name = res.data[0].subjects
        myboards[index].btn1 = res.data[0].btn1 
        myboards[index].btn1 = res.data[0].btn2
        myboards[index].btn1 = res.data[0].btn3 
        myboards[index].btn1 = res.data[0].btn4 
        that.setData(
          {
            boards: myboards
          }
        )
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      /**/db.collection("banner").get({
          success:res=>{
              console.log(res)
              this.setData({
                  mglist:res.data
              })
          }
      })
      db.collection("tzgg").get({
          success:res=>{
            console.log(res)
            this.setData({
              msgList:res.data
            })
          }
        })
        db.collection("mslb").get().then(res=>{
          console.log(res)
          this.setData({
            rmbs:res.data
          })
           })
  },
  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  showwd:function(){
    wx.navigateTo({
      url: '../jqqt/jqqd',
    })
  },
  showtk:function(){
    wx.switchTab({
      url: '../gltl/gltl',
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  }
})